package com.nchu.student_score.controller;

import com.nchu.student_score.dataObject.User;
import com.nchu.student_score.service.LoginService;
import com.nchu.student_score.vo.ResultVo;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Resource
    LoginService loginService;

    @RequestMapping("md5Test/{password}")
    public void md5Test(@PathVariable String password){
        User user = new User();
        user.setPassword(password);
        loginService.md5Test(user);
    }

    @RequestMapping("admin")
    public ResultVo<User> adminLogin(@RequestBody User user){
        return loginService.adminLogin(user);
    }

    @RequestMapping("teacher")
    public ResultVo<User> teacherLogin(@RequestBody User user){
        return loginService.teacherLogin(user);
    }

    @RequestMapping("student")
    public ResultVo<User> studentLogin(@RequestBody User user){
        return loginService.studentLogin(user);
    }
}
